import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import User from '../views/User.vue'

Vue.use(VueRouter)

// route 某个路由对象，可以理解为routes中的其中一个对象
// router 是路由器，概念比route更广

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    // meta用来不同路劲下的状态值信息,里面的键值对自由写入
    // 在组件中通过$route.meta.xxx 即可获取里面的值
    meta: { 
      isKeep:true  // 自定义一个数据，表示是否要缓存
    }
  },
  {
    path: '/user',
    name: 'User',
    component: User
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),  //路由懒加载
    meta: {
      isKeep:false
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
